package daytrader.common;
import java.io.*;
import java.util.Iterator;
import java.util.Arrays;
import java.util.List;
import daytrader.lib.LibData;

public class Utility {
	static public Boolean debug = true;
	
	static public void debug(String s) {
		if (debug) System.out.println(s);
	}
	
	static public void debug(String s1, String s2) {
		if (debug) System.out.println(s1 + " " + s2);
	}
	
	static public void debug(String s1, String s2, String s3) {
		if (debug) System.out.println(s1 + " " + s2 + " " + s3);
	}
	
	static public void debug(String s1, String s2, String s3, String s4) {
		if (debug) 
			System.out.println(s1 + " " + s2 + " " + s3 + " " + s4);
	}
	static public String getDataPath(String dataPathFileName) {
	        String dataPath;
	        if (dataPathFileName != null) {
		   try {
                        FileInputStream fis = new FileInputStream(dataPathFileName); 
                        BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
                        dataPath = in.readLine();
                   } catch (IOException e) {
			dataPath = Constants.DEFAULT_DATA_PATH;
                   }
		} else {
			dataPath = Constants.DEFAULT_DATA_PATH;
	        }
	        return dataPath;
        }
        static public Iterator enumerateStockNames(String dataPathFileName) {
                String dataPath = Utility.getDataPath(dataPathFileName);
                LibData libData = new LibData(dataPath);
                List<String> stockNames = Arrays.asList(libData.listStockNames());
                return stockNames.iterator();
        }
}
